<?php

/**
 * WebWidget Class
 *
 * @author Julot <andy.julot@gmail.com>
 * @since Wednesday, June 14, 2011. 09:38 AM
 */
class WebNewsWidget extends CWidget {

	private $_model;

	public function init() {
		$this->_model = new WebNews;
		if (isset($_POST['WebNews'])) {
			$this->_model->attributes = $_POST['WebNews'];
			if ($this->_model->save()) {
				if (defined('YII_DEBUG') && YII_DEBUG) {
				} else {
					$this->_model->sendNotification();
				}
//				$this->controller->redirect(array('news/index'));
				$this->_model->unsetAttributes();
				$this->controller->refresh();
			}
		}
	}

	public function run() {
		$this->render('webNews', array('model'=>$this->_model));
	}

}
